package com.junlong0716.enjoylearning.entity

/**
 * @author xiaobo.cui 2014年11月24日 下午5:36:29
 */
open class Contact {

    var name: String? = null
    var number: String? = null
    var simpleNumber: String? = null
    var sortKey: String? = null

    constructor() {

    }

    constructor(name: String, number: String?, sortKey: String) {
        this.name = name
        this.number = number
        this.sortKey = sortKey
        if (number != null) {
            this.simpleNumber = number.replace("\\-|\\s".toRegex(), "")
        }
    }


    override fun hashCode(): Int {
        val prime = 31
        var result = 1
        result = prime * result + if (name == null) 0 else name!!.hashCode()
        result = prime * result + if (number == null) 0 else number!!.hashCode()
        result = prime * result + if (sortKey == null) 0 else sortKey!!.hashCode()
        return result
    }

    override fun equals(obj: Any?): Boolean {
        if (this === obj)
            return true
        if (obj == null)
            return false
        if (javaClass != obj.javaClass)
            return false
        val other = obj as Contact?
        if (name == null) {
            if (other!!.name != null)
                return false
        } else if (name != other!!.name)
            return false
        if (number == null) {
            if (other.number != null)
                return false
        } else if (number != other.number)
            return false
        if (sortKey == null) {
            if (other.sortKey != null)
                return false
        } else if (sortKey != other.sortKey)
            return false
        return true
    }

}
